package com.hzhc.service.impl;

import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzhc.common.FileExcelUtil;
import com.hzhc.dto.UserDto;
import com.hzhc.entity.*;
import com.hzhc.enumBean.ResultUtilCodeEnum;
import com.hzhc.mapper.CarInfoMapper;
import com.hzhc.mapper.CompanyInfoMapper;
import com.hzhc.mapper.YwOrderCarMapper;
import com.hzhc.service.CarInfoService;
import com.hzhc.utils.EasypoiExcelUtils;
import com.hzhc.utils.ResultUtil;
import com.hzhc.utils.StringUtils;
import com.hzhc.utils.TokenUtil;
import com.hzhc.vo.CarInfoVo;
import com.hzhc.vo.CompanyInfoVo;
import lombok.AllArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * <p>
 * 车辆信息 服务实现类
 * </p>
 *
 * @author 功不唐捐
 * @since 2024-05-23
 */
@Service
@AllArgsConstructor
public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> implements CarInfoService {
     private final CompanyInfoMapper companyInfoMapper;
     private final YwOrderCarMapper ywOrderCarMapper;
    @Override
    public ResultUtil<T> selectCarInNo(CarInfo carInfo) {
        QueryWrapper<CarInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("disable", 0);
        queryWrapper.eq("car_no", carInfo.getCarNo());
        if (carInfo.getId() != null) {
            //ne 不等
            queryWrapper.ne("id", carInfo.getId());

        }
//        把之前构造的查询条件封装，进行查询
        CarInfo selectOne = baseMapper.selectOne(queryWrapper);
        if (selectOne != null) {
            return ResultUtil.build(ResultUtilCodeEnum.CAR_INFO_EXIST);
        } else {
            // String patt = "^[京津沪冀晋辽吉黑苏浙皖闽赣鲁豫鄂湘粤桂琼川黔云渝藏陕陇青宁新闽粤晋琼使领A_Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$";
            String patt = "^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$";
            Pattern r = Pattern.compile(patt);
            Matcher matcher = r.matcher(carInfo.getCarNo());

            boolean b = matcher.find();

            if (!matcher.matches()) {
                return ResultUtil.build(ResultUtilCodeEnum.CAR_INFO_TYPE);
            } else {
                return ResultUtil.ok();
            }
        }
    }

    @Override
    public List<CarInfo> getList(Page<CarInfo> pagination, CarInfoVo vo) {
        IPage<CarInfo> pageList = new Page<>();
        pageList = baseMapper.selectCarInfo(pagination, vo);
        return pageList.getRecords();
    }

    @Override
    public ResultUtil<T> addRet(CarInfo carInfo) {
        QueryWrapper<CarInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("disable", 0);
        queryWrapper.eq("car_no", carInfo.getCarNo());
        if (carInfo.getId() != null) {
            queryWrapper.ne("id", carInfo.getCarCode());
        }
        CarInfo selectOne = baseMapper.selectOne(queryWrapper);
        if (selectOne != null) {
            return ResultUtil.build(ResultUtilCodeEnum.CAR_INFO_EXIST);
        }
        carInfo.setDisable(false).setCreateTime(LocalDateTime.now());
        //插入车重数据
        carInfo.setCarWeight(carInfo.getVehicleWt());
        boolean b = save(carInfo);
        return b ? ResultUtil.ok() : ResultUtil.fail();
    }

    @Override
    public ResultUtil<T> addRet1(CarInfo info) {
        CarInfo info1 = getByCarNo(info.getCarNo());
        boolean flag = false;

        if (info1==null){
            info.setCreateTime(LocalDateTime.now());
            flag = save(info);
        }else{
            String hdId = info1.getHdId();
            hdId = hdId+","+info.getHdId();
            info1.setHdId(hdId);
            flag = updateById(info1);
        }
        if (flag){
            return ResultUtil.ok();
        }
        return ResultUtil.fail();
    }

    @Override
    public List<CarInfoVo> getCarListByVeh(CarInfoVo vo) {
        List<CarInfoVo> carListByVeh = baseMapper.getCarListByVeh(vo);
        List<YwOrderCar> ywOrderCars = ywOrderCarMapper.selectList(new QueryWrapper<YwOrderCar>().eq("disable", 0));
        for (CarInfoVo carInfoVo : carListByVeh) {
            if(ywOrderCars.size()>0){
                long count = ywOrderCars.stream().filter(s -> s.getTruckNo().equals(carInfoVo.getCarNo())).count();
                if(count>0){
                    carInfoVo.setPowerFlag(true);
                }
                if(StringUtils.isNotEmpty(carInfoVo.getVehicleWt())){
                    if(StringUtils.isNotEmpty(carInfoVo.getTowWeight())){
                        carInfoVo.setCarWeight((new BigDecimal(carInfoVo.getVehicleWt()).add(new BigDecimal(carInfoVo.getTowWeight()))).toString());
                    }else{
                        carInfoVo.setCarWeight(new BigDecimal(carInfoVo.getVehicleWt()).toString());
                    }
                }
            }
        }
        return carListByVeh;
    }

    @Override
    public ResultUtil<T> importCarList(HttpServletRequest request, List<CarInfo> carList) {
        LocalDateTime currentTime = LocalDateTime.now();
        LambdaQueryWrapper<CompanyInfo> queryWrapper = new LambdaQueryWrapper<CompanyInfo>();
        queryWrapper.select(CompanyInfo::getId, CompanyInfo::getName, CompanyInfo::getNameSimple);
        List<CompanyInfo> result = companyInfoMapper.selectList(queryWrapper);
        QueryWrapper<CarInfo> queryWrapper2 = new QueryWrapper<>();
        queryWrapper2.eq("disable", 0);
        List<CarInfo> carInfoList=new ArrayList<>(baseMapper.selectList(queryWrapper2));
        // 将CompanyInfo列表转换为Map以便快速查找
        Map<String, Long> nameToIdMap = new HashMap<>();
        for (CompanyInfo company : result) {
            nameToIdMap.put(company.getName(), company.getId());
            if (company.getNameSimple() != null) {
                nameToIdMap.put(company.getNameSimple(), company.getId());
            }
        }
        for (CarInfo car : carList) {
            List<CarInfo> collect = carInfoList.stream().filter(s -> s.getCarNo().equals(car.getCarNo())).collect(Collectors.toList());
            if (!collect.isEmpty()) {
                CarInfo carInfo = collect.get(0); // 取第一个匹配的 CarInfo
                String carInfoHdId = carInfo.getHdId(); // 获取 hdId
                // 拼接 hdId 到当前 car 的 hdId
                if (car.getHdId() == null) {
                    car.setHdId(carInfoHdId); // 如果当前 hdId 为空，直接设置
                } else {
                    car.setHdId(car.getHdId() + "," + carInfoHdId); // 否则进行拼接
                }
                car.setId(carInfo.getId());
             }
            car.setCreateTime(currentTime);
            if ( car.getInoutCar() == null ){
                car.setInoutCar(1);
            }
            // 根据 companyName 匹配 CompanyInfo 中的 id
            Long hdId = nameToIdMap.get(car.getCompanyName());
            if (hdId != null) {
                if (car.getHdId() == null) {
                    car.setHdId(Long.toString(hdId)); // 如果当前 hdId 为空，直接设置
                } else {
                    car.setHdId(car.getHdId() + "," + hdId); // 否则进行拼接
                }
            } else {
                return ResultUtil.build(ResultUtilCodeEnum.DEFAULT_HDID);
            }
        }
        boolean b = saveOrUpdateBatch(carList);
        return b ? ResultUtil.ok() : ResultUtil.fail();
    }

    @Override
    public ResultUtil<T> importYZSCarList(HttpServletRequest request, List<CarInfo> carList) {
        LocalDateTime currentTime = LocalDateTime.now();
        UserDto userDto = TokenUtil.getUser(request);
        LambdaQueryWrapper<CompanyInfo> queryWrapper = new LambdaQueryWrapper<CompanyInfo>();
        queryWrapper.select(CompanyInfo::getId, CompanyInfo::getName, CompanyInfo::getNameSimple);
        List<CompanyInfo> result = companyInfoMapper.selectList(queryWrapper);
        // 将CompanyInfo列表转换为Map以便快速查找
        Map<String, Long> nameToIdMap = new HashMap<>();
        for (CompanyInfo company : result) {
            nameToIdMap.put(company.getName(), company.getId());
            if (company.getNameSimple() != null) {
                nameToIdMap.put(company.getNameSimple(), company.getId());
            }
        }
        // 先检查车牌号是否已经存在
        boolean allCarsValid = true;

        for (CarInfo car : carList) {
            CarInfo existingCar = getByCarNo(car.getCarNo());
            if (existingCar != null) {
                if(StringUtils.isNotEmpty(existingCar.getHdId())){
                    allCarsValid = false;
                    break; // 找到已有的车牌号，跳出循环
                }else{
                    car.setId(existingCar.getId());
                }
            }
            if ( car.getInoutCar() == null ){
                car.setInoutCar(1);
            }
            // 设置创建时间和公司名称
            car.setCreateTime(currentTime);

            // 根据companyName匹配CompanyInfo中的id
            Long hdId = nameToIdMap.get(userDto.getCompanyName());
            if (hdId != null) {
                car.setHdId(Long.toString(hdId));
            } else {
                return ResultUtil.build(ResultUtilCodeEnum.DEFAULT_HDID);
            }
        }
            //车牌号已存在
        if (!allCarsValid) {
            return ResultUtil.build(ResultUtilCodeEnum.CAR_INFO_EXIST);
        }

        boolean saved = saveOrUpdateBatch(carList);
        return saved ? ResultUtil.ok() : ResultUtil.fail();
    }

    @Override
    public void exportCarFile(HttpServletRequest request, HttpServletResponse response, String exportExcelPath) {
        Map<String, Object> map = new HashMap<>();
        TemplateExportParams params = new TemplateExportParams(exportExcelPath);
        Workbook workbook = ExcelExportUtil.exportExcel(params, map);
        FileExcelUtil.downloadExcelIo(workbook, request, response, "车辆导入");
    }

    @Override
    public ResultUtil<List<CarInfoVo>> CarUpload(UserDto user, MultipartFile file) {
        List<CarInfoVo> list = new ArrayList<CarInfoVo>();
        List<String> carList = new ArrayList<String>();
        ResultUtil<List<CarInfoVo>> build = new ResultUtil<>();
        if (file != null) {
            try {
                List<CarInfoVo> planCarVos = EasypoiExcelUtils.importExcel(file, 0, 1, CarInfoVo.class);
                QueryWrapper<CarInfo> queryWrapper=new QueryWrapper<>();
                queryWrapper.eq("disable",0);
                List<CarInfo> carInfos = baseMapper.selectCarinfos();

                for (CarInfoVo c:planCarVos) { //校验数据
                    if (ObjectUtil.isEmpty(c)|| StrUtil.isBlank(c.getCarNo())){
                        c.setErrorInfo("文件中有空数据;");
                        break;
                    }
                    String errorInfo = checkCar(carList, carInfos, c.getCarNo(),c.getCompanyName());
                    if (!StrUtil.isNotBlank(c.getCarNo())) {
                        errorInfo += "车号未填;";
                    }
                    if (!StrUtil.isNotBlank(c.getCompanyName())){
                        errorInfo += "车队信息未填";
                    }
                    if (!StrUtil.isNotBlank(c.getVehicleWt())){
                        errorInfo += "车头重量未填";
                    }
                    c.setErrorInfo(errorInfo);
                    // 填充 carList 属性
                    List<CarInfo> matchedCarInfos = carInfos.stream()
                            .filter(carInfo -> carInfo.getCarNo().equals(c.getCarNo()))
                            .collect(Collectors.toList());

                    c.setCarList(matchedCarInfos);
                    list.add(c);
                }
                build = ResultUtil.build(list, ResultUtilCodeEnum.SUCCESS);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        return build;
    }

    @Override
    public void exportYzsCarFile(HttpServletRequest request, HttpServletResponse response, String exportExcelPath) {
        Map<String, Object> map = new HashMap<>();
        TemplateExportParams params = new TemplateExportParams(exportExcelPath);
        Workbook workbook = ExcelExportUtil.exportExcel(params, map);
        FileExcelUtil.downloadExcelIo(workbook, request, response, "车辆导入");
    }

    @Override
    public ResultUtil<List<CarInfoVo>> CarYzsUpload(UserDto user, MultipartFile file) {
        List<CarInfoVo> list = new ArrayList<CarInfoVo>();
        List<String> carList = new ArrayList<String>();
        ResultUtil<List<CarInfoVo>> build = new ResultUtil<>();
        if (file != null) {
            try {
                List<CarInfoVo> planCarVos = EasypoiExcelUtils.importExcel(file, 0, 1, CarInfoVo.class);
                QueryWrapper<CarInfo> queryWrapper=new QueryWrapper<>();
                queryWrapper.eq("disable",0);
                List<CarInfo> carInfos = baseMapper.selectCarinfos();
                for (CarInfoVo c:planCarVos) { //校验数据
                    if (ObjectUtil.isEmpty(c)|| StrUtil.isBlank(c.getCarNo())){
                        c.setErrorInfo("文件中有空数据;");
                        continue;
                    }
                    String errorInfo = checkYzsCar(carList, carInfos, c.getCarNo(),c.getCompanyName());
                    if (!StrUtil.isNotBlank(c.getCarNo())) {
                        errorInfo += "车号未填;";
                    }
                    if (!StrUtil.isNotBlank(c.getVehicleWt())) {
                        errorInfo += "车头重量未填;";
                    }
                    c.setErrorInfo(errorInfo);
                    // 填充 carList 属性
                    List<CarInfo> matchedCarInfos = carInfos.stream()
                            .filter(carInfo -> carInfo.getCarNo().equals(c.getCarNo()))
                            .collect(Collectors.toList());

                    c.setCarList(matchedCarInfos);
                    list.add(c);
                }
                build = ResultUtil.build(list, ResultUtilCodeEnum.SUCCESS);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        return build;
    }

    @Override
    public List<CarInfo> getCarNoByCom(CarInfo info) {
        LambdaQueryWrapper<CarInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(CarInfo::getHdId,info.getHdId())
                .eq(CarInfo::getDisable,0);
        return baseMapper.selectList(wrapper);
    }

    private String checkCar(List<String> carList, List<CarInfo> carInfoVos, String carNo,String companyName) {
        if (carNo == null || carNo.trim().isEmpty()) {
            return "车牌号不能为空;";
        }

        if (carNo.trim().length() < 7 || carNo.trim().length() > 8) {
            return "车牌号格式不正确;";
        }

        // 检查车牌号是否已经存在于列表中
        if (carList.contains(carNo)) {
            return "车牌号重复;";
        }

        // 检查车牌号是否已经存在于 carInfoVos 列表中，两个条件车牌和公司同时存在不能成立
        if(StringUtils.isNotEmpty(carNo) && StringUtils.isNotEmpty(companyName)){
            List<CompanyInfo> companyInfos = companyInfoMapper.selectList(new QueryWrapper<CompanyInfo>().eq("disable", 0).eq("car_team_flag",1));
            if(companyInfos.size()>0){
                List<CompanyInfo> collect = companyInfos.stream().filter(s -> s.getName().equals(companyName) || s.getNameSimple().equals(companyName)).collect(Collectors.toList());
                if(collect.size()>0){
                    Long id=collect.get(0).getId();
                    boolean isExisting = carInfoVos.stream().anyMatch(item ->
                            carNo.equals(item.getCarNo()) && Arrays.asList(item.getHdId().split(",")).contains(String.valueOf(id)));
                    if (isExisting) {
                        return "该车牌号在同一公司下已存在;";
                    }
                }else{
                    return "该车队名不存在";
                }
            }
        }
        // 添加到 carList 中，标记车牌号为唯一
        carList.add(carNo);
        return "";
    }
    private String checkYzsCar(List<String> carList, List<CarInfo> carInfoVos, String carNo,String companyName) {
        if (carNo == null || carNo.trim().isEmpty()) {
            return "车牌号不能为空;";
        }

        if (carNo.trim().length() < 7 || carNo.trim().length() > 8) {
            return "车牌号格式不正确;";
        }

        // 检查车牌号是否已经存在于列表中
        if (carList.contains(carNo)) {
            return "车牌号重复;";
        }

        // 检查车牌号是否已经存在于 carInfoVos 列表中，两个条件车牌和公司同时存在不能成立

        boolean isExisting = carInfoVos.stream().anyMatch(item ->
                carNo.equals(item.getCarNo()) && companyName.equals(item.getCompanyName())
        );
        if (isExisting) {
            return "该车牌号在同一公司下已存在;";
        }
        // 添加到 carList 中，标记车牌号为唯一
        carList.add(carNo);
        return "";
    }

    @Override
    public ResultUtil<T> updateRet(CarInfo vo) {
        QueryWrapper<CarInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("disable",0);
        queryWrapper.eq("car_no", vo.getCarNo());
        if(vo.getId()!=null){
            queryWrapper.ne("id",vo.getId());
        }
        CarInfo selectOne = baseMapper.selectOne(queryWrapper);
        if(selectOne!=null){
            return ResultUtil.build(ResultUtilCodeEnum.CAR_INFO_EXIST);
        }
        CarInfo carInfo = getById(vo.getId());
        //插入车重数据
        carInfo.setCarWeight(carInfo.getVehicleWt());
        carInfo.setTowId(vo.getTowId());
        LambdaUpdateWrapper<CarInfo> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(CarInfo::getId, vo.getId());
        updateWrapper.set(vo.getHdId() == null, CarInfo::getHdId, null);
        updateWrapper.set(vo.getTowId() == null, CarInfo::getTowId, null);
        Boolean b = update(vo, updateWrapper);
        return b ? ResultUtil.ok() : ResultUtil.fail();
    }

    @Override
    public ResultUtil<T> delCarInfo(CarInfo carInfo) {
        carInfo.setDisable(true);
        boolean b =updateById(carInfo);
        return b?ResultUtil.ok():ResultUtil.fail();
    }

    @Override
    public List<CompanyInfoVo> getCarTeamPage(Page<CompanyInfoVo> page, CompanyInfoVo vo) {
        IPage<CompanyInfoVo> pageList = companyInfoMapper.selectCarTeam(page, vo);
        return pageList.getRecords();
    }

    @Override
    public List<CarInfo> getCarJsonPage(CarInfoVo vo, Page<CarInfo> page) {
        return baseMapper.selectCarJsonPage(page,vo).getRecords();
    }
    @Override
    public List<CarInfoVo> getYZSCarJsonPage(CarInfoVo vo, Page<CarInfoVo> page) {
        return baseMapper.selectYZSCarJsonPage(page,vo).getRecords();
    }

    @Override
    public List<CarInfo> getCarNoList(CarInfo car) {
        return baseMapper.getCarNoList(car);
    }

    @Override
    public List<CarInfoVo> getSgjYwCarList(CarInfoVo vo) {
        return baseMapper.getSgjYwCarList(vo);
    }

    @Override
    public void checkCarNo(String carNo,Long companyId) {
        CarInfo carInfo = baseMapper.selectOne(new QueryWrapper<CarInfo>().eq("disable", 0).eq("car_no", carNo));
        if(carInfo==null){
            CarInfo info=new CarInfo();
            info.setCarNo(carNo);
            info.setInoutCar(1);
            info.setHdId(String.valueOf(companyId));
            info.setCreateTime(LocalDateTime.now());
            baseMapper.insert(info);
        }
    }


    @Override
    public List<CarInfoVo> checkCarNoS(String carNo, Long companyId) {
        // 查询不被禁用的车辆信息
        List<CarInfo> carInfoList = baseMapper.selectList(new QueryWrapper<CarInfo>()
                .eq("disable", 0)
                .eq("car_no", carNo)
                .eq("hd_id", String.valueOf(companyId)));

        // 将查询结果转换为 CarInfoVo
        return carInfoList.stream()
                .map(carInfo -> {
                    CarInfoVo carInfoVo = new CarInfoVo();
                    carInfoVo.setCarNo(carInfo.getCarNo());
                    carInfoVo.setInoutCar(carInfo.getInoutCar());
                    carInfoVo.setHdId(carInfo.getHdId());
                    carInfoVo.setCreateTime(carInfo.getCreateTime());
                    return carInfoVo;
                })
                .collect(Collectors.toList());
    }


    @Override
    public ResultUtil<T> checkIsBlack(CarInfo carInfo) {
        CarInfo info = getById(carInfo.getId());
        if (info.getIsBlack()==1){
            return ResultUtil.build(400,"该车辆为黑名单！");
        }
        return ResultUtil.ok();
    }

    @Override
    public CarInfo getByCarNo(String carNo) {
        return baseMapper.getByCarNo(carNo);
    }

    @Override
    public List<CarInfo> getByCarNos(String carNo, String companyName) {
        return baseMapper.getByCarNos(carNo, companyName);
    }

    @Override
    public ResultUtil<T> deleteById(CarInfoVo vo) {
        CarInfo info = getById(vo.getId());
        String companyId = info.getHdId();
        String id = vo.getCompanyId();//yzs操作人companyid
        String[] split = companyId.split(",");
        List<String> list = Arrays.asList(split);
        List<String> list1 = list.stream().filter(item -> !item.equals(id)).collect(Collectors.toList());
        String join = StringUtils.join(list1, ",");
        info.setHdId(join);
        boolean b = updateById(info);
        if (b){
            return ResultUtil.ok();
        }
        return ResultUtil.fail();
    }

    @Override
    public ResultUtil<T> carNoCheck(CarInfo carInfo) {//yzs
        LambdaQueryWrapper<CarInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(CarInfo::getCarNo,carInfo.getCarNo())
                .like(CarInfo::getHdId,carInfo.getCompanyId())
                .eq(CarInfo::getDisable,0);
        if(carInfo.getId()!=null){
            wrapper.ne(CarInfo::getId,carInfo.getId());
        }
        int count = count(wrapper);
        if (count>0){
            return ResultUtil.build(ResultUtilCodeEnum.CAR_INFO_EXIST);
        }else{
            // String patt = "^[京津沪冀晋辽吉黑苏浙皖闽赣鲁豫鄂湘粤桂琼川黔云渝藏陕陇青宁新闽粤晋琼使领A_Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$";
            String patt = "^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$";
            Pattern r = Pattern.compile(patt);
            Matcher matcher = r.matcher(carInfo.getCarNo());

            boolean b = matcher.find();

            if (!matcher.matches()) {
                return ResultUtil.build(ResultUtilCodeEnum.CAR_INFO_TYPE);
            } else {
                return ResultUtil.ok();
            }
        }
    }



}
